<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:v-on="http://www.w3.org/1999/xhtml"
      xmlns:v-bind="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>检测者列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../js/vue.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">sinoare</a>
        <a href="">报表管理</a>
        <a>
          <cite>检测指标统览</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body" id="table_Div">
    <div class="layui-row layui-bg-gray">
        <br />
        <form class="layui-form layui-col-md12 x-so" style="width: 800px;">
            <div class="layui-inline">
                <label for="L_pass" class="layui-form-label"> 姓名 </label>
                <div class="layui-input-inline">
                    <input type="text" name="username" id="cname" placeholder="请输入姓名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label for="L_pass" class="layui-form-label"> 电话号码 </label>
                <div class="layui-input-inline">
                    <input class="layui-input" id="cphone" placeholder="请输入联系电话">
                </div>
            </div>
            <br/><br/>
            <div class="layui-inline" >
                <label for="L_pass" class="layui-form-label"> 所属总店</label>
                <div class="layui-input-inline">
                    <!--所属总店-->
                    <select name="zong" id="zong" lay-filter="zong">
                        <option value="全部">全部</option>
                        <option th:each="ho : ${headOffices}" th:text="${ho.hname}"></option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label for="L_pass" class="layui-form-label"> 所属分店</label>
                <div class="layui-input-inline">
                    <!--所属分店-->
                    <select name="feng" lay-filter="feng" id="feng">
                        <option>全部</option>
                    </select>
                </div>
            </div>
        </form>
        <div class="layui-inline" style="margin-left: 900px; margin-top: -96px;">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach" v-on:click="chaXun" id="btn_customer"><i class="layui-icon">&#xe615;</i>查询</button>
            <button class="layui-btn "  id="reset"><i class="layui-icon"></i>重置</button>
        </div>
    </div>

    <div class="layui-bg-gray">
        <table class="layui-table" style="width: 1060px;margin-left: 10px;">
            <thead>
            <tr>
                <th width="40px">
                    <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                </th>
                <th width="80px"></th>
                <th width="130px">姓名</th>
                <th width="100px">性别</th>
                <th width="100px">年龄</th>
                <th width="200px">所属总店</th>
                <th width="250px">所属分店</th>
                <th width="200px">电话号码</th>

            </thead>
            <tbody>
            <tr v-for="(common,index) in getPage.currentAllData">
                <td>
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
                </td>
                <td>{{index+1}}</td>
                <td>{{common.cname}}</td>
                <td v-if="common.csex == '0'">女</td>
                <td v-if="common.csex == '1'">男</td>
                <td>{{common.cage}}</td>
                <td>{{common.branchOffice.bname}}</td>
                <td>{{common.branchOffice.headOffice.hname}}</td>
                <td>{{common.cphone}}</td>
            </tr>
            </tbody>
        </table>
        <div class="page">
            <div>
                <a class="prev" v-on:click="beforePage">&lt;&lt;</a>
                <span v-for="pageSum in getPage.pageSum">
                    <span class="current" v-if="pageSum == getPage.currentPage+1">{{pageSum}}</span>
                    <a class="num" v-else v-on:click="change(pageSum)">{{pageSum}}</a>
                </span>
                <a class="next" v-on:click="nextPage">&gt;&gt;</a>
            </div>
        </div>
    </div>
</div>
<div class="layui-bg-gray" style="width: 1277px;margin-left: 19px;">
    <form class="layui-form layui-col-md12 x-so" style="width: 800px;">
        <br/>
        <div class="layui-inline">
            <label for="L_pass" class="layui-form-label"> 筛选周期</label>
            <div class="layui-input-inline">
                <select name="province" lay-filter="province">
                    <option value="">近七天</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label for="L_pass" class="layui-form-label"> 查询指标</label>
            <div class="layui-input-inline">
                <select name="province" lay-filter="province">
                    <option value="">全部</option>
                </select>
            </div>
        </div>

    </form>
    <div class="layui-inline" style="margin-left: 1070px; margin-top: -96px;">
        <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>查询</button>
        <button class="layui-btn "><i class="layui-icon"></i>导出报表</button>
    </div>
</div>
</div>
<script th:inline="javascript">

    layui.use(['form', 'layer','laydate'],function() {
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer;

        form.on('select(zong)',function (data) {
            $.ajax({
                url:"/bnameHnameOption",
                type:"POST",
                data:{
                    "hname":data.value
                },
                success: function (result) {
                    $("#feng option").remove();
                    var data = result.data;
                    var tem = "<option>全部</option>";
                    for(var re in data){
                        tem += "<option>"+data[re].bname+"</option>";
                    }
                    $("#feng").html(tem);
                    form.render();
                }
            })
        })
    });

    $(function () {
        var table_Div = new Vue({
            el: "#table_Div",
            data(){
                return{
                    CommonResult:{
                        data:""
                    },
                    getPage:{
                        //当前所有数据
                        currentAllData:[],
                        //每页显示条数
                        pageSize:10,
                        //总页
                        pageSum:0,
                        //当前页数
                        currentPage:0
                    }
                };
            },
            mounted(){
                var _this = this;
                $.ajax({
                    url:"/getExaminer",
                    type:"POST",
                    success:function (result) {
                        _this.CommonResult = result;

                        //总页数
                        _this.getPage.pageSum = Math.ceil(_this.CommonResult.data.listIndexSum.length/_this.getPage.pageSize);
                        //当前页数
                        var currentPage = _this.getPage.currentPage;

                        for (var i = currentPage*_this.getPage.pageSize; i < _this.CommonResult.data.listIndexSum.length; i++){
                            if (i < _this.getPage.pageSize) {
                                _this.getPage.currentAllData.push(_this.CommonResult.data.listIndexSum[i]);
                            }
                        }
                    }
                })
            },
            methods:{
                chaXun : function () {
                    var cname = $("#cname").val();
                    var cphone = $("#cphone").val();
                    var bname = $("#feng").val();
                    var hname = $("#zong").val();
                    var _this = this;
                    $.ajax({
                        url:"/getExaminer",
                        type:"post",
                        data:{
                            "cname":cname,
                            "cphone":cphone,
                            "bname":bname,
                            "hname":hname
                        },
                        success:function (result) {
                            _this.CommonResult = result;
                            _this.getPage.currentAllData = [];
                            //总页数
                            _this.getPage.pageSum = Math.ceil(_this.CommonResult.data.listIndexSum.length/_this.getPage.pageSize);
                            //当前页数
                            var currentPage = _this.getPage.currentPage;

                            for (var i = currentPage*_this.getPage.pageSize; i < _this.CommonResult.data.listIndexSum.length; i++){
                                if (i < _this.getPage.pageSize) {
                                    _this.getPage.currentAllData.push(_this.CommonResult.data.listIndexSum[i]);
                                }
                            }
                        }
                    })
                },

                beforePage : function () {
                    var _this = this;
                    _this.getPage.currentAllData = [];

                    if (_this.getPage.currentPage != 0) {
                        _this.getPage.currentPage -= 1;
                    }

                    var j = 0;
                    for (var i = _this.getPage.currentPage*_this.getPage.pageSize; i < _this.CommonResult.data.listIndexSum.length; i++){
                        if (j <_this.getPage.pageSize){
                            _this.getPage.currentAllData.push(_this.CommonResult.data.listIndexSum[i]);
                        }
                        j++;
                    }
                },

                nextPage : function () {
                    var _this = this;
                    _this.getPage.currentAllData = [];

                    if (_this.getPage.currentPage != _this.getPage.pageSum-1){
                        _this.getPage.currentPage += 1;
                    }

                    var j = 0;
                    for (var i = _this.getPage.pageSize * _this.getPage.currentPage; i < _this.CommonResult.data.listIndexSum.length; i++){
                        if (j < _this.getPage.pageSize){
                            _this.getPage.currentAllData.push(_this.CommonResult.data.listIndexSum[i]);
                        }
                        j++;
                    }
                },

                change:function (page) {
                    var _this = this;
                    _this.getPage.currentAllData = [];
                    _this.getPage.currentPage = page - 1;

                    var j = 0;
                    for (var i = _this.getPage.currentPage*_this.getPage.pageSize; i < _this.CommonResult.data.listIndexSum.length; i++){
                        if (j < _this.getPage.pageSize){
                            _this.getPage.currentAllData.push(_this.CommonResult.data.listIndexSum[i]);
                        }
                        j++;
                    }
                }
            }
        });



        $("#reset").click(function () {
            $("#cname").val("");
            $("#cphone").val("");
        })

    })

    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });




    /*用户-停用*/
    function member_stop(obj,id){
        layer.confirm('确认要停用吗？',function(index){

            if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

            }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
            }

        });
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }

    function delAll (argument) {

        var data = tableCheck.getData();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
            $(".layui-form-checked").not('.header').parents('tr').remove();
        });
    }
</script>
</body>

</html>